<template>
  <div id="aCoursesList" class="bg-fa of">
    <!-- /课程详情 开始 -->
    <section class="container">
      <section class="path-wrap txtOf hLh30">
        <a href="#" title class="c-999 fsize14">首页</a>
        \
        <a href="#" title class="c-999 fsize14">资产列表</a>
        \
        <span class="c-333 fsize14">{{info.title}}</span>
      </section>
      <div>
        <article class="c-v-pic-wrap" style="height: 250px;">
          <section class="p-h-video-box" id="videoPlay" style="margin-left:100px">
            <img width="50%" :src="info.cover" :alt="info.title" class="dis c-v-pic">
          </section>
        </article>
        <aside class="c-attr-wrap" style="height: 250px;">
          <section class="ml20 mr15">
            <h2 class="hLh30 txtOf mt15">
              <span class="c-fff fsize24">{{info.title}}</span>
            </h2>
            <section class="c-attr-jg">
              <span class="c-fff">资产价值：</span>
              <b class="c-yellow" style="font-size:24px;">{{info.price}}元</b>
            </section>
            <section class="c-attr-mt">
              <a title="借用" class="comm-btn c-btn-3" @click="open">借用</a>
            </section>
          </section>
        </aside>
        <aside class="thr-attr-box" style="height: 250px;">
          <ol class="thr-attr-ol clearfix">
            <li>
              <p>&nbsp;</p>
              <aside>
                <span class="c-fff f-fM">借出次数</span>
                <br>
                <h6 class="c-fff f-fM mt10">{{info.count}}</h6>
              </aside>
            </li>
            <li>
              <aside>
                <span class="c-fff f-fM">录入时间</span>
                <br>
                <h6 class="c-fff f-fM mt10">{{info.gmtCreate}}</h6>
              </aside>
            </li>
            <li>
              <aside>
                <span class="c-fff f-fM">编号</span>
                <br>
                <h6 class="c-fff f-fM mt10">{{info.id}}</h6>
              </aside>
            </li>
          </ol>
        </aside>
        <div class="clear"></div>
      </div>
    </section>
    <!-- 课程详情介绍 开始 -->
    <div class="mt20 c-infor-box">
        <article class="fl col-7">
          <section class="mr30">
            <div class="i-box">
              <div>
                <section id="c-i-tabTitle" class="c-infor-tabTitle c-tab-title">
                  <a name="c-i" class="current" title="详情">详情</a>
                </section>
              </div>
              <article class="ml10 mr10 pt20">
                <div>
                    <h6 class="c-i-content c-infor-title">
                        <span>介绍</span>
                    </h6>
                    <div class="course-txt-body-wrap">
                        <section class="course-txt-body">
                            <!-- 将内容中的html翻译过来 -->
                            <p v-html="info.description">{{ info.description }}</p>
                        </section>
                    </div>
                </div>
              </article>
            </div>
          </section>
        </article>
    </div>
    <!-- /课程详情介绍 结束 -->
  </div>
</template>

<script>
import assetApi from '@/api/asset'

export default {
  data(){
    return{
     out:{}
    }
  },
  asyncData({params, error}){
    return assetApi.getAssetById(params.id)
    .then(res => {
      return{
          info : res.data.data.info
      }
    })
  },
  methods:{
    open() {
      this.$prompt('请填写申请理由', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(({ value }) => {
        this.out.assetId = this.info.id;
        this.out.des = value;
        assetApi.outAsset(this.out)
          .then(res => {
            this.$message({
                type: 'success',
                message: '申请成功'
              }); 
            this.$router.push({path:'/asset'})
          })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });       
      });
    }
  }
};
</script>
